import { BaseEnvMirror } from "@/modules/dev-env/mirror/mirror.ts";
import type { ToolInstallVersionItem } from "@/modules/dev-env/common/types.ts";
import { Spider } from "@/ipc/spider.ts";

export class NacosStableMirror extends BaseEnvMirror {
  constructor() {
    super({
      id: "nacos.stable",
      name: "稳定版",
      url: "https://nacos.io/download/nacos-server",
      website: "https://nacos.io/",
    });
  }

  async getDownloadList(query: Record<string, any>): Promise<ToolInstallVersionItem[]> {
    const versions = await Spider.getNacosStableVersions();
    return versions.map(it => ({
      id: "nacos-" + it.name,
      name: it.name,
      url: it.url,
      version: it.version,
    }));
  }
}
